/*
 *  Class name: ControlsDialog.java
 *  Version: 1.0
 *  Date: 2.5.2014
 */
package cz.muni.fi.pv112.cranesimulator.gui;

import cz.muni.fi.pv112.cranesimulator.gui.components.ControlKeyTextField;
import cz.muni.fi.pv112.cranesimulator.gui.components.handlers.ControlKeysHandler;
import cz.muni.fi.pv112.cranesimulator.settings.Controls;
import javax.swing.JOptionPane;

/**
 *
 * @author Michal Ďuriš
 */
public class ControlsDialog extends javax.swing.JDialog {

    private static final long serialVersionUID = 1L;

    /**
     * Creates new form ControlsDialog
     *
     * @param parent
     * @param modal
     */
    public ControlsDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

        setLocationRelativeTo(parent);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        controlsTabbedPanel = new javax.swing.JTabbedPane();
        cameraControlsPanel = new javax.swing.JPanel();
        cameraMovementPanel = new javax.swing.JPanel();
        moveCameraForwardTextField = new ControlKeyTextField(Controls.Key.MOVE_CAMERA_FORWARD);
        moveCameraLeftTextField = new ControlKeyTextField(Controls.Key.MOVE_CAMERA_LEFT);
        moveIconLabel = new javax.swing.JLabel();
        moveCameraRightTextField = new ControlKeyTextField(Controls.Key.MOVE_CAMERA_RIGHT);
        moveCameraBackwardTextField = new ControlKeyTextField(Controls.Key.MOVE_CAMERA_BACKWARD);
        cameraModesPanel = new javax.swing.JPanel();
        freeCameraModeLabel = new javax.swing.JLabel();
        freeCameraModeTextField = new ControlKeyTextField(Controls.Key.FREE_CAMERA_MODE);
        cabinCameraModeLabel = new javax.swing.JLabel();
        cabinCameraModeTextField = new ControlKeyTextField(Controls.Key.CABIN_CAMERA_MODE);
        magnetCameraModeLabel = new javax.swing.JLabel();
        magnetCameraModeTextField = new ControlKeyTextField(Controls.Key.MAGNET_CAMERA_MODE);
        craneControlsPanel = new javax.swing.JPanel();
        cranesMagnetPanel = new javax.swing.JPanel();
        cranesMagnetIconLabel = new javax.swing.JLabel();
        magnetUpLabel = new javax.swing.JLabel();
        magnetUpTextField = new ControlKeyTextField(Controls.Key.MAGNET_UP);
        magnetDownLabel = new javax.swing.JLabel();
        magnetDownTextField = new ControlKeyTextField(Controls.Key.MAGNET_DOWN);
        magnetEnableLabel = new javax.swing.JLabel();
        magnetEnableTextField = new ControlKeyTextField(Controls.Key.MAGNET_ENABLED);
        cranesRiderPanel = new javax.swing.JPanel();
        cranesRiderIconLabel = new javax.swing.JLabel();
        riderForwardLabel = new javax.swing.JLabel();
        riderForwardTextField = new ControlKeyTextField(Controls.Key.RIDER_FORWARD);
        riderBackwardLabel = new javax.swing.JLabel();
        riderBackwardTextField = new ControlKeyTextField(Controls.Key.RIDER_BACKWARD);
        cranesOperatingPartPanel = new javax.swing.JPanel();
        operatingPartIconLabel = new javax.swing.JLabel();
        operatingPartRotateLeftLabel = new javax.swing.JLabel();
        operatingPartRotateLeftTextField = new ControlKeyTextField(Controls.Key.OPERATION_PART_ROTATION_LEFT);
        operationPartRotateRightLabel = new javax.swing.JLabel();
        operationPartRotateRightTextField = new ControlKeyTextField(Controls.Key.OPERATION_PART_ROTATION_RIGHT);
        actionButtonsPanel = new javax.swing.JPanel();
        saveButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Controls");
        setMinimumSize(new java.awt.Dimension(340, 530));
        getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.PAGE_AXIS));

        controlsTabbedPanel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        cameraMovementPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Movement"));
        cameraMovementPanel.setLayout(new java.awt.GridBagLayout());

        moveCameraForwardTextField.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        moveCameraForwardTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
        cameraMovementPanel.add(moveCameraForwardTextField, gridBagConstraints);

        moveCameraLeftTextField.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        moveCameraLeftTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
        cameraMovementPanel.add(moveCameraLeftTextField, gridBagConstraints);

        moveIconLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        moveIconLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cz/muni/fi/pv112/cranesimulator/resources/menu/icons/Move-icon.png"))); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        cameraMovementPanel.add(moveIconLabel, gridBagConstraints);

        moveCameraRightTextField.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        moveCameraRightTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
        cameraMovementPanel.add(moveCameraRightTextField, gridBagConstraints);

        moveCameraBackwardTextField.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        moveCameraBackwardTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
        cameraMovementPanel.add(moveCameraBackwardTextField, gridBagConstraints);

        cameraModesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Modes"));
        java.awt.GridBagLayout cameraModesPanelLayout = new java.awt.GridBagLayout();
        cameraModesPanelLayout.columnWidths = new int[] {0, 10, 0, 10, 0};
        cameraModesPanelLayout.rowHeights = new int[] {0, 5, 0};
        cameraModesPanel.setLayout(cameraModesPanelLayout);

        freeCameraModeLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        freeCameraModeLabel.setText("Free");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        cameraModesPanel.add(freeCameraModeLabel, gridBagConstraints);

        freeCameraModeTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        cameraModesPanel.add(freeCameraModeTextField, gridBagConstraints);

        cabinCameraModeLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        cabinCameraModeLabel.setText("Cabine");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        cameraModesPanel.add(cabinCameraModeLabel, gridBagConstraints);

        cabinCameraModeTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        cameraModesPanel.add(cabinCameraModeTextField, gridBagConstraints);

        magnetCameraModeLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        magnetCameraModeLabel.setText("Magnet");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 0;
        cameraModesPanel.add(magnetCameraModeLabel, gridBagConstraints);

        magnetCameraModeTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 2;
        cameraModesPanel.add(magnetCameraModeTextField, gridBagConstraints);

        javax.swing.GroupLayout cameraControlsPanelLayout = new javax.swing.GroupLayout(cameraControlsPanel);
        cameraControlsPanel.setLayout(cameraControlsPanelLayout);
        cameraControlsPanelLayout.setHorizontalGroup(
            cameraControlsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cameraControlsPanelLayout.createSequentialGroup()
                .addGroup(cameraControlsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cameraModesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cameraMovementPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE))
                .addGap(0, 0, 0))
        );
        cameraControlsPanelLayout.setVerticalGroup(
            cameraControlsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, cameraControlsPanelLayout.createSequentialGroup()
                .addComponent(cameraModesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cameraMovementPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE))
        );

        controlsTabbedPanel.addTab("Camera", cameraControlsPanel);

        craneControlsPanel.setLayout(new java.awt.GridLayout(3, 1));

        cranesMagnetPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Magnet"));

        cranesMagnetIconLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cz/muni/fi/pv112/cranesimulator/resources/menu/icons/Crane-icon-magnet.png"))); // NOI18N

        magnetUpLabel.setText("Up");

        magnetUpTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        magnetDownLabel.setText("Down");

        magnetDownTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        magnetEnableLabel.setText("Enable/disable");

        magnetEnableTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        javax.swing.GroupLayout cranesMagnetPanelLayout = new javax.swing.GroupLayout(cranesMagnetPanel);
        cranesMagnetPanel.setLayout(cranesMagnetPanelLayout);
        cranesMagnetPanelLayout.setHorizontalGroup(
            cranesMagnetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cranesMagnetPanelLayout.createSequentialGroup()
                .addComponent(cranesMagnetIconLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(cranesMagnetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(cranesMagnetPanelLayout.createSequentialGroup()
                        .addGroup(cranesMagnetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(cranesMagnetPanelLayout.createSequentialGroup()
                                .addComponent(magnetDownLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(magnetDownTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE))
                            .addGroup(cranesMagnetPanelLayout.createSequentialGroup()
                                .addComponent(magnetEnableLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(magnetEnableTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)))
                        .addGap(10, 10, 10))
                    .addGroup(cranesMagnetPanelLayout.createSequentialGroup()
                        .addComponent(magnetUpLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(magnetUpTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
                        .addContainerGap())))
        );

        cranesMagnetPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {magnetDownLabel, magnetEnableLabel, magnetUpLabel});

        cranesMagnetPanelLayout.setVerticalGroup(
            cranesMagnetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cranesMagnetPanelLayout.createSequentialGroup()
                .addGroup(cranesMagnetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(cranesMagnetPanelLayout.createSequentialGroup()
                        .addGroup(cranesMagnetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(magnetUpLabel)
                            .addComponent(magnetUpTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(cranesMagnetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(magnetDownTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(magnetDownLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(cranesMagnetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(magnetEnableLabel)
                            .addComponent(magnetEnableTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(cranesMagnetIconLabel))
                .addGap(0, 0, Short.MAX_VALUE))
        );

        craneControlsPanel.add(cranesMagnetPanel);

        cranesRiderPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Rider"));

        cranesRiderIconLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cz/muni/fi/pv112/cranesimulator/resources/menu/icons/Crane-icon-rider.png"))); // NOI18N

        riderForwardLabel.setText("Forward");

        riderForwardTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        riderBackwardLabel.setText("Backward");

        riderBackwardTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        javax.swing.GroupLayout cranesRiderPanelLayout = new javax.swing.GroupLayout(cranesRiderPanel);
        cranesRiderPanel.setLayout(cranesRiderPanelLayout);
        cranesRiderPanelLayout.setHorizontalGroup(
            cranesRiderPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cranesRiderPanelLayout.createSequentialGroup()
                .addComponent(cranesRiderIconLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(cranesRiderPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(cranesRiderPanelLayout.createSequentialGroup()
                        .addComponent(riderBackwardLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(riderBackwardTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE))
                    .addGroup(cranesRiderPanelLayout.createSequentialGroup()
                        .addComponent(riderForwardLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(riderForwardTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)))
                .addContainerGap())
        );

        cranesRiderPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {riderBackwardLabel, riderForwardLabel});

        cranesRiderPanelLayout.setVerticalGroup(
            cranesRiderPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cranesRiderPanelLayout.createSequentialGroup()
                .addGroup(cranesRiderPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cranesRiderIconLabel)
                    .addGroup(cranesRiderPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(cranesRiderPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(riderForwardLabel)
                            .addComponent(riderForwardTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(cranesRiderPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(riderBackwardTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(riderBackwardLabel))))
                .addGap(0, 0, 0))
        );

        craneControlsPanel.add(cranesRiderPanel);

        cranesOperatingPartPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Operating part"));

        operatingPartIconLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cz/muni/fi/pv112/cranesimulator/resources/menu/icons/Crane-icon-rotation-part.png"))); // NOI18N

        operatingPartRotateLeftLabel.setText("Rotate left:");

        operatingPartRotateLeftTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        operationPartRotateRightLabel.setText("Rotate right:");

        operationPartRotateRightTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        javax.swing.GroupLayout cranesOperatingPartPanelLayout = new javax.swing.GroupLayout(cranesOperatingPartPanel);
        cranesOperatingPartPanel.setLayout(cranesOperatingPartPanelLayout);
        cranesOperatingPartPanelLayout.setHorizontalGroup(
            cranesOperatingPartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cranesOperatingPartPanelLayout.createSequentialGroup()
                .addComponent(operatingPartIconLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(cranesOperatingPartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(cranesOperatingPartPanelLayout.createSequentialGroup()
                        .addComponent(operationPartRotateRightLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(operationPartRotateRightTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE))
                    .addGroup(cranesOperatingPartPanelLayout.createSequentialGroup()
                        .addComponent(operatingPartRotateLeftLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(operatingPartRotateLeftTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)))
                .addContainerGap())
        );

        cranesOperatingPartPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {operatingPartRotateLeftLabel, operationPartRotateRightLabel});

        cranesOperatingPartPanelLayout.setVerticalGroup(
            cranesOperatingPartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cranesOperatingPartPanelLayout.createSequentialGroup()
                .addGroup(cranesOperatingPartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(operatingPartIconLabel)
                    .addGroup(cranesOperatingPartPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(cranesOperatingPartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(operatingPartRotateLeftLabel)
                            .addComponent(operatingPartRotateLeftTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(cranesOperatingPartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(operationPartRotateRightLabel)
                            .addComponent(operationPartRotateRightTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(0, 0, 0))
        );

        craneControlsPanel.add(cranesOperatingPartPanel);

        controlsTabbedPanel.addTab("Crane", craneControlsPanel);

        getContentPane().add(controlsTabbedPanel);

        actionButtonsPanel.setMaximumSize(new java.awt.Dimension(32767, 25));
        actionButtonsPanel.setMinimumSize(new java.awt.Dimension(100, 25));

        saveButton.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        saveButton.setText("Save");
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        cancelButton.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout actionButtonsPanelLayout = new javax.swing.GroupLayout(actionButtonsPanel);
        actionButtonsPanel.setLayout(actionButtonsPanelLayout);
        actionButtonsPanelLayout.setHorizontalGroup(
            actionButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, actionButtonsPanelLayout.createSequentialGroup()
                .addContainerGap(146, Short.MAX_VALUE)
                .addComponent(saveButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cancelButton)
                .addGap(14, 14, 14))
        );

        actionButtonsPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancelButton, saveButton});

        actionButtonsPanelLayout.setVerticalGroup(
            actionButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, actionButtonsPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(actionButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cancelButton)
                    .addComponent(saveButton))
                .addContainerGap())
        );

        actionButtonsPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {cancelButton, saveButton});

        getContentPane().add(actionButtonsPanel);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        try {
            ControlKeysHandler.getInstance().storeAllControlKeys();
            dispose();
        } catch (RuntimeException ex) {
            JOptionPane.showMessageDialog(this,
                    "Unable to save your controls configuration! :(",
                    "Error",
                    JOptionPane.ERROR_MESSAGE);

            System.err.println(ex.toString());
        }
    }//GEN-LAST:event_saveButtonActionPerformed

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        dispose();
    }//GEN-LAST:event_cancelButtonActionPerformed

    public void showDialog() {
        try {
            ControlKeysHandler.getInstance().loadAllControlKeys();
            setVisible(true);
        } catch (RuntimeException ex) {
            JOptionPane.showMessageDialog(this,
                    "Unable to show control dialog window! ",
                    "Error",
                    JOptionPane.ERROR_MESSAGE);

            System.err.println(ex.toString());
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel actionButtonsPanel;
    private javax.swing.JLabel cabinCameraModeLabel;
    private javax.swing.JTextField cabinCameraModeTextField;
    private javax.swing.JPanel cameraControlsPanel;
    private javax.swing.JPanel cameraModesPanel;
    private javax.swing.JPanel cameraMovementPanel;
    private javax.swing.JButton cancelButton;
    private javax.swing.JTabbedPane controlsTabbedPanel;
    private javax.swing.JPanel craneControlsPanel;
    private javax.swing.JLabel cranesMagnetIconLabel;
    private javax.swing.JPanel cranesMagnetPanel;
    private javax.swing.JPanel cranesOperatingPartPanel;
    private javax.swing.JLabel cranesRiderIconLabel;
    private javax.swing.JPanel cranesRiderPanel;
    private javax.swing.JLabel freeCameraModeLabel;
    private javax.swing.JTextField freeCameraModeTextField;
    private javax.swing.JLabel magnetCameraModeLabel;
    private javax.swing.JTextField magnetCameraModeTextField;
    private javax.swing.JLabel magnetDownLabel;
    private javax.swing.JTextField magnetDownTextField;
    private javax.swing.JLabel magnetEnableLabel;
    private javax.swing.JTextField magnetEnableTextField;
    private javax.swing.JLabel magnetUpLabel;
    private javax.swing.JTextField magnetUpTextField;
    private javax.swing.JTextField moveCameraBackwardTextField;
    private javax.swing.JTextField moveCameraForwardTextField;
    private javax.swing.JTextField moveCameraLeftTextField;
    private javax.swing.JTextField moveCameraRightTextField;
    private javax.swing.JLabel moveIconLabel;
    private javax.swing.JLabel operatingPartIconLabel;
    private javax.swing.JLabel operatingPartRotateLeftLabel;
    private javax.swing.JTextField operatingPartRotateLeftTextField;
    private javax.swing.JLabel operationPartRotateRightLabel;
    private javax.swing.JTextField operationPartRotateRightTextField;
    private javax.swing.JLabel riderBackwardLabel;
    private javax.swing.JTextField riderBackwardTextField;
    private javax.swing.JLabel riderForwardLabel;
    private javax.swing.JTextField riderForwardTextField;
    private javax.swing.JButton saveButton;
    // End of variables declaration//GEN-END:variables
}
